<template>
  <div>
    <preview
      v-if="printType === 'preview' || !silentService"
      ref="preview"
      :name="name"
      @close="close"
    />
    <silent
      v-else
      ref="silent"
      :name="name"
      @close="close"
      @fetch-data="fetchData"
    />
  </div>
</template>

<script>
  import Preview from './preview'
  import Silent from './silent'
  import { mapGetters } from 'vuex'
  // import { doPrint } from '@/api/gfPrint'
  // import { printData } from '@/utils/constant'
  export default {
    components: {
      Preview,
      Silent,
    },
    props: {
      name: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        silentService: true,
      }
    },
    computed: {
      ...mapGetters(['printType']),
    },
    methods: {
      show(row) {
        if (this.printType === 'preview') {
          this.$refs.preview.show(row)
        } else {
          this.$refs.silent.show(row)
        }
      },
      close() {
        this.$emit('getAll')
      },
      fetchData() {
        this.$emit('fetchData')
      },
    },
  }
</script>

<style lang="scss" scoped></style>
